package net.mysoft.budgetsoft.system.interceptor;

import java.util.Arrays;
import java.util.List;

import net.mysoft.framework.base.BaseAction;

import com.opensymphony.xwork2.ActionInvocation;

/**
 * session拦截器
 * @author kangrui
 *
 */
public class SessionInterceptor extends BaseInterceptor {
	
	private static final List<String> excludes = Arrays.asList(new String[]{"/login/check.action"});

	/**
	 * 
	 */
	private static final long serialVersionUID = 4170146712704494179L;

	@Override
	public String deal(ActionInvocation ai) throws Exception {
		String contextPath = super.getRequest().getContextPath();
		String requestURI = super.getRequest().getRequestURI();
		String url = requestURI.replaceFirst(contextPath, "");
		if(!excludes.contains(url)) {
			Object user = super.getSession().getAttribute(BaseAction.LOGIN_USER);
			if(user==null) return "noSession";
		}
		return ai.invoke();
	}
}
